#ifndef __IOCMD_H__
#define __IOCMD_H__

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <unistd.h>				/* for close */
#include <linux/wireless.h>
#include <errno.h>

#define MAGIC_CODE_WIFI                0x3142
#define IOCTL_CMD_TEST	            (SIOCDEVPRIVATE + 0)
#define IOCTL_CMD_SET			    (SIOCDEVPRIVATE + 1)

#define SSID_MAXLEN               32
#define BSSID_LEN             	 6

#if WIRELESS_EXT <= 11
#ifndef SIOCDEVPRIVATE
#define SIOCDEVPRIVATE			0x8BE0
#endif
#define SIOCIWFIRSTPRIV			SIOCDEVPRIVATE
#endif
#define RT_PRIV_IOCTL (SIOCIWFIRSTPRIV + 0x0E)
#define OID_GEN_MEDIA_CONNECT_STATUS 0x060B// Defines the state of the LAN media

#pragma pack(1)
typedef struct tagSCmdRequest 
{
	u8 	    name[16];	
	void	*  data;
	u16	    wResult;
	u16      wCmdCode;
} SCmdRequest, *PSCmdRequest;

typedef struct tagSCmdLinkStatus 
{
	BOOL   bLink;
	u16	    wBSSType;
	u8       byState;    
	u8       abyBSSID[BSSID_LEN];
	u8       abySSID[SSID_MAXLEN + 2];
	u32     uChannel;
	u32     uLinkRate;
    
} SCmdLinkStatus, *PSCmdLinkStatus;	


typedef enum _NDIS_MEDIA_STATE
{	
	NdisMediaStateConnected,	
	NdisMediaStateDisconnected
} NDIS_MEDIA_STATE, *PNDIS_MEDIA_STATE;

#pragma pack()


/*
#define ADHOC	0
#define INFRA	1
#define BOTH	2
#define AP	    3

#define ADHOC_STARTED	   1
#define ADHOC_JOINTED	   2

   
#define PHY80211a 	    0
#define PHY80211b       1
#define PHY80211g       2   

#define SSID_ID                0


#define WEP_NKEYS              4
#define WEP_KEYMAXLEN          29
#define WEP_40BIT_LEN          5
#define WEP_104BIT_LEN         13 
#define WEP_232BIT_LEN         16 

typedef struct tagSCmdStartAP {
    
    u16	    wBSSType;
    u16     wBBPType;
    u8	    ssid[SSID_MAXLEN + 2];
    u32 	uChannel;
    u32     uBeaconInt;
    BOOL    bShareKeyAuth;
    u8      byBasicRate;

} SCmdStartAP, *PSCmdStartAP;

typedef struct tagSDot11MIBCount {
    u32 TransmittedFragmentCount;
    u32 MulticastTransmittedFrameCount;
    u32 FailedCount;
    u32 RetryCount;
    u32 MultipleRetryCount;
    u32 RTSSuccessCount;
    u32 RTSFailureCount;
    u32 ACKFailureCount;
    u32 FrameDuplicateCount;
    u32 ReceivedFragmentCount;
    u32 MulticastReceivedFrameCount;
    u32 FCSErrorCount;
} SDot11MIBCount, DEF* PSDot11MIBCount;

typedef struct tagSStatMIBCount {
    //
    // ISR status count
    //
    u32   dwIsrTx0OK;
    u32   dwIsrTx1OK;
    u32   dwIsrBeaconTxOK;
    u32   dwIsrRxOK;
    u32   dwIsrTBTTInt;
    u32   dwIsrSTIMERInt;
    u32   dwIsrUnrecoverableError;
    u32   dwIsrSoftInterrupt;
    u32   dwIsrRxNoBuf;

    u32   dwIsrUnknown;               // unknown interrupt count

    u32   dwRsrFrmAlgnErr;
    u32   dwRsrErr;
    u32   dwRsrCRCErr;
    u32   dwRsrCRCOk;
    u32   dwRsrBSSIDOk;
    u32   dwRsrADDROk;
    u32   dwRsrICVOk;
    u32   dwNewRsrShortPreamble;
    u32   dwRsrLong;
    u32   dwRsrRunt;
        
    u32   dwRsrRxControl;
    u32   dwRsrRxData;
    u32   dwRsrRxManage;

    u32   dwRsrRxPacket;
    u32   dwRsrRxOctet;
    u32   dwRsrBroadcast;
    u32   dwRsrMulticast;
    u32   dwRsrDirected;
    // 64-bit OID
    u32   ullRsrOK;
    
    // for some optional OIDs (64 bits) and DMI support    
    u32   ullRxBroadcastBytes;
    u32   ullRxMulticastBytes;
    u32   ullRxDirectedBytes;
    u32   ullRxBroadcastFrames;
    u32   ullRxMulticastFrames;
    u32   ullRxDirectedFrames;    

    u32   dwRsrRxFragment;
    u32   dwRsrRxFrmLen64;
    u32   dwRsrRxFrmLen65_127;
    u32   dwRsrRxFrmLen128_255;
    u32   dwRsrRxFrmLen256_511;
    u32   dwRsrRxFrmLen512_1023;
    u32   dwRsrRxFrmLen1024_1518;

    // TSR0,1 status count
    //
    u32   dwTsrTotalRetry[2];        // total collision retry count
    u32   dwTsrOnceRetry[2];         // this packet only occur one collision
    u32   dwTsrMoreThanOnceRetry[2]; // this packet occur more than one collision
    u32   dwTsrRetry[2];             // this packet has ever occur collision, 
                                       // that is (dwTsrOnceCollision0 + dwTsrMoreThanOnceCollision0)
    u32   dwTsrACKData[2];
    u32   dwTsrErr[2];                   
    u32   dwAllTsrOK[2];
    u32   dwTsrRetryTimeout[2];
    u32   dwTsrTransmitTimeout[2];

    u32   dwTsrTxPacket[2];
    u32   dwTsrTxOctet[2];
    u32   dwTsrBroadcast[2];
    u32   dwTsrMulticast[2];
    u32   dwTsrDirected[2];

    // RD/TD count
    u32   dwCntRxFrmLength;
    u32   dwCntTxBufLength;

    u8    abyCntRxPattern[16];
    u8    abyCntTxPattern[16];

    // Software check....
    u32   dwCntRxDataErr;             // rx buffer data software compare CRC err count
    u32   dwCntDecryptErr;            // rx buffer data software compare CRC err count
    u32   dwCntRxICVErr;              // rx buffer data software compare CRC err count
    u32    idxRxErrorDesc;             // index for rx data error RD

    // 64-bit OID
    u32   ullTsrOK[2];
    
    // for some optional OIDs (64 bits) and DMI support
    u32   ullTxBroadcastFrames[2];
    u32   ullTxMulticastFrames[2];
    u32   ullTxDirectedFrames[2];    
    u32   ullTxBroadcastBytes[2];
    u32   ullTxMulticastBytes[2];
    u32   ullTxDirectedBytes[2];
} SStatMIBCount, DEF* PSStatMIBCount;

#define VIAWGET_HOSTAPD_GENERIC_ELEMENT_HDR_LEN \
((int) (&((struct viawget_hostapd_param *) 0)->u.generic_elem.data))

struct viawget_hostapd_param {
	u32 cmd;
	u8 sta_addr[6];
	union {
		struct {
			u16 aid;
			u16 capability;
			u8 tx_supp_rates;
		} add_sta;
		struct {
			u32 inactive_sec;
		} get_info_sta;
		struct {
			u8 alg;
			u32 flags;
			u32 err;
			u8 idx;
			u8 seq[8]; 
			u16 key_len;
			u8 key[0];
		} crypt;
		struct {
			u32 flags_and;
			u32 flags_or;
		} set_flags_sta;
		struct {
			u16 rid;
			u16 len;
			u8 data[0];
		} rid;
		struct {
			u8 len;
			u8 data[0];
		} generic_elem;
		struct {
			u16 cmd;
			u16 reason_code;
		} mlme;
		struct {
			u8 ssid_len;
			u8 ssid[32];
		} scan_req;
	} u;
};
*/

#endif //__IOCMD_H__
